<%@page import="java.sql.Connection" import="java.sql.Statement" import="java.sql.ResultSet" %>
<%@ page import="connection.DBConnection" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>VAT Computation</title>
</head>
<body>
<form name="vat">
<center> <h2> VAT Computation</h2></center>
<table border=0 align=center>

<tr> 
		<td><b>Tax collected on Sale: </b></td>
</tr> 

			<%	 DBConnection dbc=new DBConnection();	
				 Connection con=dbc.getNewConnection();
				 double S12=0.0;				
				 Statement st = null;
				 ResultSet rs = null;
			try
			{
			   st=con.createStatement() ;
       		   rs=st.executeQuery("select SUM(stamount) from SalesVoucher2 where staxcat='12.5' "); 

      		   	while(rs.next())
      		 	{ 
           		 S12=rs.getDouble(1);
        		} 
     
	 		}
			catch(Exception e)
			{ e.printStackTrace(); } %>

<tr>
		<td> 12.5% </td>
		<td> <input type="text" value="<%=S12 %>" > </td>
</tr>

			<%	 
				 double S5=0.0;	 
			try
			{
			   st=con.createStatement() ;
       		   rs=st.executeQuery("select SUM(stamount) from SalesVoucher2 where staxcat='5.0' ");
	
       		   while(rs.next())
       		   { 
            		 S5=rs.getDouble(1);
         	   } 
      
	 		}
			catch(Exception e)
			{ e.printStackTrace(); } %>

<tr>
		<td> 5% </td>
		<td> <input type="text" value="<%=S5 %>" > </td>
</tr>

<tr>
		<td> Total </td>
		<td> <input type="text" value="<%=S5+S12 %>" > </td>
</tr>

<tr> 
		<td> &nbsp </td>
</tr>

<tr> 
		<td><b>Tax Credit on Purchase: </b></td>
</tr> 

			<%	 
				 double P12=0.0;	 
			try
			{
			   st=con.createStatement() ;
       		   rs=st.executeQuery("select SUM(pvtaxa) from PurchaseVoucher2 where pvtaxcat='12.5' "); 
	
       		   while(rs.next())
       		   { 
            		 P12=rs.getDouble(1);
         	   } 
      
	 		}
		    catch(Exception e)
		    { e.printStackTrace(); } %>

<tr>
		<td> 12.5% </td>
		<td> <input type="text" value="<%=P12 %>" > </td>
</tr>

			<%	 
				 double P5=0.0;	 
			try
			{
			   st=con.createStatement() ;
       		   rs=st.executeQuery("select SUM(pvtaxa) from PurchaseVoucher2 where pvtaxcat='5.0' ");
	
       		   while(rs.next())
       		   { 
            		 P5=rs.getDouble(1);
         	   } 
      
	 		 }
			catch(Exception e)
			{ e.printStackTrace(); } %>

<tr>
		<td> 5% </td>
		<td> <input type="text" value="<%=P5 %>"> </td>
</tr>

<tr>
		<td> Total </td>
		<td> <input type="text" value="<%=P5+P12 %>" > </td>
</tr>

<tr> 
		<td> &nbsp </td>
</tr>

<tr> 
		<td><b>Net Tax payable </b></td>
		<td> <input type="text" value="<%=S5+S12-P5-P12 %>" > </td>
</tr> 
</table>

</form>
</body>
</html>